package lion.framework.core.web.anno;

import java.lang.annotation.Annotation;

import lion.dev.lang.InterceptorAdaptor;
import lion.dev.lang.MapJ;
import lion.framework.core.anno.AnnoProcessor;
import lion.framework.core.anno.AnnotationProcessorManager;
import lion.framework.core.anno.IAnnotationProcessor;
import lion.framework.core.web.path.ExecutorInterceptorManager;

/**
 * @author lion
 * @email hl_0074@sina.com
 * @date 2015年4月18日
 */
@AnnoProcessor(ExecuteInterceptor.class)
public class ExecuteInterceptorProcessor implements IAnnotationProcessor {

	@SuppressWarnings("unchecked")
	@Override
	public void processe(MapJ ctx, Annotation anno) throws Exception {

		Class<?> clazz = ctx.getE(AnnotationProcessorManager.ANNO_CONTEXT_TARGET);
		if (!InterceptorAdaptor.class.isAssignableFrom(clazz)) { return; }

		ExecuteInterceptor execAnno = (ExecuteInterceptor) anno;

		ExecutorInterceptorManager.registe(new ExecuteInterceptorSpec((Class<? extends InterceptorAdaptor>) clazz, execAnno.value()));
	}
}
